<?php
include("../includes/DBFunctions.php");
include("../includes/getCredentials.php");


function removeEnvironmentEventFunctor( $env ) {
	$gc = new GetCredentials;
	$uid = $gc->getUserID();
	$db = new DBFunctions;
	$db->connectDB();
	$result = $db->query("call removeEnvironmentEvent(".$env.",".$uid.",@a)" );;
	$errors = $db->query("SELECT @a");
	while( $line = mysqli_fetch_array( $errors, MYSQL_ASSOC ) ) {
		$error = $line['@a'];
	}
	if( !$result || $error != 0 ) {
		die( "Failed stored procedure call (removeEnvironmentEvent ErrorCode:".$error.")" );
	}
}

if( !isset($_POST['removeID']) || $_POST['removeID'] == '') {
	die("alert('No environment event was selected. Please try again.');");
}
$env = $_POST['removeID'];

removeEnvironmentEventFunctor( $env );
?>